# Maintainer: Maksim Bondarenkov <maksapple2306@gmail.com>

_realname=muon
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.4.0
pkgrel=1
pkgdesc="Meson implementation in C (mingw-w64)"
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
url='https://muon.build'
license=('spdx:GPL-3.0-only')
msys2_references=(
  'aur: muon-meson'
)
msys2_repository_url='https://git.sr.ht/~lattis/muon'
makedepends=("${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-scdoc"
             "${MINGW_PACKAGE_PREFIX}-cc"
             'git')
depends=("${MINGW_PACKAGE_PREFIX}-ninja"
         "${MINGW_PACKAGE_PREFIX}-pkgconf"
         "${MINGW_PACKAGE_PREFIX}-curl"
         "${MINGW_PACKAGE_PREFIX}-libarchive")
source=("git+${msys2_repository_url}#tag=${pkgver}")
sha256sums=('51a61ebb9d8d03d3c37dc282c4eb2c5de8c71dfbf1a5b94ad186cbf2a0db1050')

build() {
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    meson setup \
      --prefix="${MINGW_PREFIX}" \
      --wrap-mode=nodownload \
      --default-library=shared \
      --auto-features=enabled \
      --buildtype=plain \
      -Ddocs=enabled \
      -Dtracy=disabled \
      "build-${MSYSTEM}" \
      "${_realname}"

  meson compile -C "build-${MSYSTEM}"
}

check() {
  meson test -C "build-${MSYSTEM}"
}

package() {
  meson install -C "build-${MSYSTEM}" --destdir "${pkgdir}"

  install -Dm644 "${_realname}/LICENSES/GPL-3.0-only.txt" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
